<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
    // prototype
      function Person(name, age) {
        this.name = name;
        this.age = age;
      }

      Person.prototype.sex = "男";
      Person.prototype.work = function (workType) {
        console.log(this.name + "的工作是：" + workType);
      };
      var p1 = new Person("王大头", 18);
      console.log(p1);
      p1.work("程序员");

      console.log(p1.__proto__); //__proto__是一个指向prototype的地址指针

    //  constructor
      var arr = [];
      console.log(arr.constructor === Array); //true

      var isTrue = new Boolean();
      console.log(isTrue.constructor === Array); //false
      console.log(isTrue.constructor === Boolean);  //true

    // 用typeof测试引用类型的数据时,返回的都是object
      console.log(typeof arr); //object
      console.log(typeof isTrue); // object
    </script>
  </body>
</html>
